﻿<BaseUI:UserControlBase xmlns:c1rtb="clr-namespace:C1.Silverlight.RichTextBox;assembly=C1.Silverlight.RichTextBox" 
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:BaseUI="clr-namespace:Silverlight.Weblog.Client.Default.Widgets.BaseUI"
	mc:Ignorable="d"
                        
    xmlns:VM="clr-namespace:Silverlight.Weblog.Client.Default.Widgets.ViewModels"
     
    xmlns:SampleData="clr-namespace:Expression.Blend.SampleData.BlogPostViewModelSampleData"
     
    xmlns:Commands="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
     
    xmlns:System="clr-namespace:System;assembly=mscorlib"
     
    d:DesignWidth="640" d:DesignHeight="480"
	x:Class="Silverlight.Weblog.Client.Default.Widgets.BlogPostWidget"
                        
     VerticalAlignment="Top"  
		>
	<BaseUI:UserControlBase.Resources>
		<SampleData:BlogPostViewModelSampleData x:Key="BlogPostViewModelSampleData" d:IsDataSource="True"/>
		<DataTemplate x:Key="CategoriesItemTemplate">
			<StackPanel Orientation="Horizontal">
				<HyperlinkButton Content="{Binding Name}" FontFamily="Arial" FontSize="13.333"  
                                 Commands:Click.Command="{Binding RaiseNavigateToCategoryEvent}"
                                 Commands:Click.CommandParameter="{Binding Model}"
                                />
				<TextBlock Text=", " TextWrapping="Wrap"/>
			</StackPanel>
		</DataTemplate>
		<ItemsPanelTemplate x:Key="ItemsPanelTemplateHorizontalStackPanel">
			<StackPanel Orientation="Horizontal" />
		</ItemsPanelTemplate>
		<DataTemplate x:Key="BlogPostChildCategoriesViewModelsItemTemplate">
			<StackPanel Orientation="Horizontal">
				<HyperlinkButton Content="{Binding Model.Name}" 
					Commands:Click.Command="{Binding RaiseNavigateToCategoryEvent}"
					Commands:Click.CommandParameter="{Binding Model}"
                                />
				<TextBlock Text=", " Visibility="{Binding CommaVisiblity}" />
			</StackPanel>
		</DataTemplate>
		<ControlTemplate x:Key="ValidationToolTipTemplate">
			<Grid x:Name="Root" Margin="5,0" Opacity="0" RenderTransformOrigin="0,0">
				<VisualStateManager.VisualStateGroups>
					<VisualStateGroup x:Name="OpenStates">
						<VisualStateGroup.Transitions>
							<VisualTransition GeneratedDuration="0"/>
							<VisualTransition GeneratedDuration="0:0:0.2" To="Open">
								<Storyboard>
									<DoubleAnimationUsingKeyFrames Storyboard.TargetName="xform" Storyboard.TargetProperty="X">
										<SplineDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
									</DoubleAnimationUsingKeyFrames>
									<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity">
										<SplineDoubleKeyFrame KeyTime="0:0:0.2" Value="1"/>
									</DoubleAnimationUsingKeyFrames>
								</Storyboard>
							</VisualTransition>
						</VisualStateGroup.Transitions>
						<VisualState x:Name="Closed">
							<Storyboard>
								<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity">
									<SplineDoubleKeyFrame KeyTime="0" Value="0"/>
								</DoubleAnimationUsingKeyFrames>
							</Storyboard>
						</VisualState>
						<VisualState x:Name="Open">
							<Storyboard>
								<DoubleAnimationUsingKeyFrames Storyboard.TargetName="xform" Storyboard.TargetProperty="X">
									<SplineDoubleKeyFrame KeyTime="0" Value="0"/>
								</DoubleAnimationUsingKeyFrames>
								<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Root" Storyboard.TargetProperty="Opacity">
									<SplineDoubleKeyFrame KeyTime="0" Value="1"/>
								</DoubleAnimationUsingKeyFrames>
							</Storyboard>
						</VisualState>
					</VisualStateGroup>
				</VisualStateManager.VisualStateGroups>
				<Grid.RenderTransform>
					<TranslateTransform x:Name="xform" X="-25"/>
				</Grid.RenderTransform>
				<Border Margin="4,4,-4,-4" Background="#052A2E31" CornerRadius="5"/>
				<Border Margin="3,3,-3,-3" Background="#152A2E31" CornerRadius="4"/>
				<Border Margin="2,2,-2,-2" Background="#252A2E31" CornerRadius="3"/>
				<Border Margin="1,1,-1,-1" Background="#352A2E31" CornerRadius="2"/>
				<Border Background="#FFDC000C" CornerRadius="2"/>
				<Border CornerRadius="2">
					<TextBlock Margin="8,4,8,4" MaxWidth="250" UseLayoutRounding="false" Foreground="White" Text="{Binding (Validation.Errors)[0].ErrorContent}" TextWrapping="Wrap"/>
				</Border>
			</Grid>
		</ControlTemplate>
		<Style x:Key="TextBlockLikeTextBox" TargetType="TextBox">
			<Setter Property="BorderThickness" Value="1"/>
			<Setter Property="Background" Value="#FFFFFFFF"/>
			<Setter Property="Foreground" Value="#FF000000"/>
			<Setter Property="Padding" Value="2"/>
			<Setter Property="BorderBrush">
				<Setter.Value>
					<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
						<GradientStop Color="#FFA3AEB9" Offset="0"/>
						<GradientStop Color="#FF8399A9" Offset="0.375"/>
						<GradientStop Color="#FF718597" Offset="0.375"/>
						<GradientStop Color="#FF617584" Offset="1"/>
					</LinearGradientBrush>
				</Setter.Value>
			</Setter>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="TextBox">
						<Grid x:Name="RootElement">
							<VisualStateManager.VisualStateGroups>
								<VisualStateGroup x:Name="CommonStates">
									<VisualState x:Name="Normal">
										<Storyboard>
											<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
												<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0.5"/>
											</DoubleAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="MouseOver">
										<Storyboard>
											<ColorAnimationUsingKeyFrames Storyboard.TargetName="MouseOverBorder" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)">
												<SplineColorKeyFrame KeyTime="0" Value="#FF99C1E2"/>
											</ColorAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="Disabled">
										<Storyboard>
											<DoubleAnimationUsingKeyFrames Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity">
												<SplineDoubleKeyFrame KeyTime="0" Value="1"/>
											</DoubleAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="ReadOnly">
										<Storyboard>
											<DoubleAnimationUsingKeyFrames Storyboard.TargetName="ReadOnlyVisualElement" Storyboard.TargetProperty="Opacity">
												<SplineDoubleKeyFrame KeyTime="0" Value="1"/>
											</DoubleAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Border" Storyboard.TargetProperty="(Border.CornerRadius)">
												<DiscreteObjectKeyFrame KeyTime="00:00:00">
													<DiscreteObjectKeyFrame.Value>
														<CornerRadius>0</CornerRadius>
													</DiscreteObjectKeyFrame.Value>
												</DiscreteObjectKeyFrame>
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
								<VisualStateGroup x:Name="FocusStates">
									<VisualState x:Name="Focused">
										<Storyboard>
											<DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity">
												<SplineDoubleKeyFrame KeyTime="0" Value="1"/>
											</DoubleAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="Unfocused">
										<Storyboard>
											<DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity">
												<SplineDoubleKeyFrame KeyTime="0" Value="0"/>
											</DoubleAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
								<VisualStateGroup x:Name="ValidationStates">
									<VisualState x:Name="Valid"/>
									<VisualState x:Name="InvalidUnfocused">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationErrorElement" Storyboard.TargetProperty="Visibility">
												<DiscreteObjectKeyFrame KeyTime="0">
													<DiscreteObjectKeyFrame.Value>
														<Visibility>Visible</Visibility>
													</DiscreteObjectKeyFrame.Value>
												</DiscreteObjectKeyFrame>
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="InvalidFocused">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationErrorElement" Storyboard.TargetProperty="Visibility">
												<DiscreteObjectKeyFrame KeyTime="0">
													<DiscreteObjectKeyFrame.Value>
														<Visibility>Visible</Visibility>
													</DiscreteObjectKeyFrame.Value>
												</DiscreteObjectKeyFrame>
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip" Storyboard.TargetProperty="IsOpen">
												<DiscreteObjectKeyFrame KeyTime="0">
													<DiscreteObjectKeyFrame.Value>
														<System:Boolean>True</System:Boolean>
													</DiscreteObjectKeyFrame.Value>
												</DiscreteObjectKeyFrame>
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
							</VisualStateManager.VisualStateGroups>
							<Border x:Name="Border" Opacity="1" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
								<Grid x:Name="grid" RenderTransformOrigin="0.5,0.5">
									<Grid.RenderTransform>
										<TransformGroup>
											<ScaleTransform/>
											<SkewTransform/>
											<RotateTransform/>
											<TranslateTransform/>
										</TransformGroup>
									</Grid.RenderTransform>
									<Border x:Name="ReadOnlyVisualElement" Opacity="0"/>
									<Border x:Name="MouseOverBorder" BorderBrush="Transparent">
										<ScrollViewer x:Name="ContentElement" BorderThickness="0" IsTabStop="False" Padding="{TemplateBinding Padding}"/>
									</Border>
								</Grid>
							</Border>
							<Border x:Name="DisabledVisualElement" IsHitTestVisible="False" Opacity="0" Background="#A5F7F7F7" BorderBrush="#A5F7F7F7" BorderThickness="{TemplateBinding BorderThickness}"/>
							<Border x:Name="FocusVisualElement" Margin="1" IsHitTestVisible="False" Opacity="0" BorderBrush="#FF6DBDD1" BorderThickness="{TemplateBinding BorderThickness}"/>
							<Border x:Name="ValidationErrorElement" Visibility="Collapsed" BorderBrush="#FFDB000C" BorderThickness="1" CornerRadius="1">
								<ToolTipService.ToolTip>
									<ToolTip x:Name="validationTooltip" Template="{StaticResource ValidationToolTipTemplate}" DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}" Placement="Right" PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}">
										<ToolTip.Triggers>
											<EventTrigger RoutedEvent="Canvas.Loaded">
												<BeginStoryboard>
													<Storyboard>
														<ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip" Storyboard.TargetProperty="IsHitTestVisible">
															<DiscreteObjectKeyFrame KeyTime="0">
																<DiscreteObjectKeyFrame.Value>
																	<System:Boolean>true</System:Boolean>
																</DiscreteObjectKeyFrame.Value>
															</DiscreteObjectKeyFrame>
														</ObjectAnimationUsingKeyFrames>
													</Storyboard>
												</BeginStoryboard>
											</EventTrigger>
										</ToolTip.Triggers>
									</ToolTip>
								</ToolTipService.ToolTip>
								<Grid Height="12" HorizontalAlignment="Right" Margin="1,-4,-4,0" VerticalAlignment="Top" Width="12" Background="Transparent">
									<Path Fill="#FFDC000C" Margin="1,3,0,0" Data="M 1,0 L6,0 A 2,2 90 0 1 8,2 L8,7 z"/>
									<Path Fill="#ffffff" Margin="1,3,0,0" Data="M 0,0 L2,0 L 8,6 L8,8"/>
								</Grid>
							</Border>
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	</BaseUI:UserControlBase.Resources>
        <Grid d:DataContext="{Binding Source={StaticResource BlogPostViewModelSampleData}}">
		<Image Height="59" Margin="0,0,70,0" VerticalAlignment="Top" Source="PostHeader.jpg" Stretch="None" HorizontalAlignment="Left"/>
		<StackPanel Margin="12,19,3,45" Orientation="Vertical" d:LayoutOverrides="Height">
			<HyperlinkButton Commands:Click.Command="{Binding RaiseGoToBlogPostPermlinkEvent}"  
                             Commands:Click.CommandParameter="{Binding Model.Permlink}"
                             HorizontalAlignment="Left" Margin="5,0,150,0" FontWeight="Bold" FontFamily="Arial" FontSize="34.667">
				<TextBlock Text="{Binding Model.Title}" TextWrapping="Wrap" />
			</HyperlinkButton>
			<c1rtb:C1RichTextBox x:Name="c1RTB" IsReadOnly="True" Html="{Binding Html, Mode=OneWay}" DisabledCuesVisibility="Collapsed" VerticalScrollBarVisibility="Auto" ReturnMode="HardLineBreak" NavigationMode="Always" VerticalAlignment="Stretch" BorderThickness="0" Background="Transparent" HideCaret="True" />
		</StackPanel>
        	<Border BorderBrush="#FFDBDBDC" BorderThickness="1,0,1,1" Margin="0,57,0,0" CornerRadius="2"/>
        	<Border Margin="3,57,3,3" BorderBrush="#FFDBDBDC" BorderThickness="1,0,1,1" CornerRadius="2"/>
        	<Border BorderBrush="#FFDBDBDC" Margin="565,54,0,0" CornerRadius="2" BorderThickness="0,1,1,0"/>
        	<Border Margin="565,57,3,7" BorderBrush="#FFDBDBDC" CornerRadius="2" BorderThickness="0,1,0,0"/>
        	<TextBlock HorizontalAlignment="Right" Margin="0,10,10,0" VerticalAlignment="Top" Text="{Binding FormattedBlogPostCreatedDate}" TextWrapping="Wrap" Foreground="#FF1084FF" FontSize="16" FontFamily="Trebuchet MS"/>
        	<StackPanel Margin="12,0,-106,6" VerticalAlignment="Bottom" Orientation="Vertical">
        		<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
        			<TextBlock Text="Posted By: " TextWrapping="Wrap" d:LayoutOverrides="Height"/>
        			<TextBlock Text="{Binding AuthorName, Mode=OneWay}" TextWrapping="Wrap" d:LayoutOverrides="Height" Margin="5,0,0,0" FontWeight="Bold"/>
        			<TextBlock Text="{Binding FiledUnder, Mode=OneWay}" TextWrapping="Wrap"/>
        			<ItemsControl ItemTemplate="{StaticResource BlogPostChildCategoriesViewModelsItemTemplate}" ItemsSource="{Binding BlogPostChildCategoriesViewModels}" ItemsPanel="{StaticResource ItemsPanelTemplateHorizontalStackPanel}"/>
        			<Border BorderBrush="Black" Visibility="{Binding ShowTwitterLink}" VerticalAlignment="Center">
        				<StackPanel Orientation="Horizontal">
        					<TextBlock HorizontalAlignment="Left" Text=" | " TextWrapping="Wrap"/>
        					<HyperlinkButton Content="Twitter this blog post!" NavigateUri="{Binding TwitterThisLink}" TargetName="_blank"/>
        				</StackPanel>
        			</Border>
        		</StackPanel>
    
        		<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
        			<TextBlock Text="Permanent Link: " TextWrapping="Wrap" VerticalAlignment="Center"/>
        			<TextBox BorderBrush="White" Foreground="Black" Padding="0" Height="17" Style="{StaticResource TextBlockLikeTextBox}" VerticalAlignment="Center" IsReadOnly="True" Text="{Binding FullPermlink, Mode=TwoWay}" TextWrapping="Wrap" d:LayoutOverrides="Width" BorderThickness="0" Margin="0,0,0,3"/>
        		</StackPanel>
        	</StackPanel>
    
	</Grid>
    
</BaseUI:UserControlBase>